package dbStruct;

import dbConnections.DBConnection;
import edu.umd.cs.piccolo.PNode;

public class Column extends Node{
	private int pos;
	private int type;
	private int dim;
	private String typeName;
	private boolean index;
	private boolean primary;
	
	public Column()
	{
		super(NodeType.COLUMN);
	}
	
	public Column(String name){
		super(NodeType.COLUMN);
		super.setName(name);
	}
	
	public String getName()	{
		return super.getName();
	}
	
	public void setName(String name){
		super.setName(name);
	}
	
	public int getColumnType() {
		return type;
	}
	public void setColumnType(int type) {
		this.type = type;
		this.typeName=DBConnection.getTypeName(type);
	}
	public int getDim() {
		return dim;
	}
	public void setDim(int dim) {
		this.dim = dim;
	}
	public boolean isIndex() {
		return index;
	}
	public void setIndex(boolean index) {
		this.index = index;
	}
	public boolean isPrimary() {
		return primary;
	}
	public void setPrimary(boolean primary) {
		this.primary = primary;
	}
	public String getTypeName(){
		return this.typeName;
	}
	public int getOrdinalPosition(){
		return this.pos;
	}
	public void setOrdinalPosition(int position){
		this.pos=position;
	}
	public String getColumnName()	{
		String columnName = super.getName();
		columnName = columnName.substring(columnName.indexOf(".")+1);
		return columnName;
	}
	public String getTableName(){
		String tableName = super.getName();
		tableName = tableName.substring(0,tableName.indexOf("."));
		return tableName;
	}
	public PNode getPNode()	{
		return super.getNode();
	}
	public void setPNode(PNode node){
		super.setNode(node);
	}
}
